﻿using System;

namespace Gmantis.Uploader
{
    public class UploaderPost : Uploader
    {
        // Events
        public event MIMETypeRequestedEventHandler MIMETypeRequested;

        // Methods
        public UploaderPost(FilesPerRequest filePackager)
            : this(new UploadManagerSettingsPost(), FilePackagerFactory.Create(filePackager))
        {
        }

        public UploaderPost(UploadManagerSettingsPost settings)
            : this(settings, new FilePackagerSingleFile())
        {
        }

        public UploaderPost(Uri address)
            : this(new UploadManagerSettingsPost(address))
        {
        }

        public UploaderPost(UploadManagerSettingsPost settings, FilePackager filePackager)
            : base(settings, filePackager, new UploadManagerPost())
        {
            (base._manager as UploadManagerPost).Uploader = this;
        }

        internal string OnMIMETypeRequested(string fileExtension)
        {
            if (this.MIMETypeRequested != null)
            {
                return this.MIMETypeRequested(this, new MIMETypeRequestedEventArgs(fileExtension));
            }
            return "";
        }

        // Properties
        public UploadManagerSettingsPost Settings
        {
            get
            {
                return (base.Settings as UploadManagerSettingsPost);
            }
        }

        // Nested Types
        public delegate string MIMETypeRequestedEventHandler(object sender, MIMETypeRequestedEventArgs e);
    }
}
